package com.max.xihu.lambda;

import java.util.Comparator;
import java.util.TreeSet;

/**
 * @Author: Max
 * @Date: 2020-03-24 21:54
 * @Description:
 */
public class LambdaDemo {

    public static void main(String[] args) {


        //使用lambda之前

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("lambda表达式之前");
            }
        }).start();


        //使用lambda之后
//        new Thread(()->{
//            System.out.println("lambda表达式之后");
//        }).start();
        new Thread(() -> System.out.println("lambda表达式之后")).start();


    }

    public void compareIntegerV1(){
        Comparator<Integer> comparator = new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return Integer.compare(o1,o2);
            }
        };

        TreeSet<Integer> treeSet = new TreeSet<>(comparator);
    }


    public void compareIntegerV2(){
        Comparator<Integer> comparator = (o1, o2) -> Integer.compare(o1,o2);
        TreeSet<Integer> treeSet = new TreeSet<>(comparator);
    }
}
